package com.atguigu.mvc.handler;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CookieValue;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;

@Controller
public class Operation06Handler {

    private Logger logger = LoggerFactory.getLogger(this.getClass());

    @RequestMapping("/obtain/request/header")
    public String obtainRequestHeader(

            // 通过 @RequestHeader 注解获取请求消息头
            // 在注解的 value 属性中指定请求消息头的名称
            @RequestHeader("Accept-Language") String acceptLanguage
    ) {

        logger.debug("acceptLanguage = " + acceptLanguage);

        return "target";
    }

    @RequestMapping("/obtain/cookie/value")
    public String obtainCookieValue(
            @CookieValue(value = "JSESSIONID", defaultValue = "NULL") String sessionId,
            HttpSession session
    ) {

        logger.debug("sessionId = " + sessionId);

        return "target";
    }

}
